package com.damei.qmui_test_demo.activity.home;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.damei.qmui_test_demo.R;
import com.damei.qmui_test_demo.base.BaseActivity;
import com.damei.qmui_test_demo.httpService.HttpManager;
import com.damei.qmui_test_demo.httpService.HttpStringResponseHandler;
import com.damei.qmui_test_demo.model.MeiZiResponse;
import com.damei.qmui_test_demo.model.PersonModel;
import com.damei.qmui_test_demo.service.NavigationCallBack;
import com.damei.qmui_test_demo.view.DataListAdapter;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DataListActivity extends BaseActivity {

    @BindView(R.id.data_list_view)
    ListView listView;

    @BindView(R.id.refresh_layout)
    RefreshLayout refreshLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_data_list);
        ButterKnife.bind(this);

        setNavigationAction("数据总览", R.color.colorNavigation, new NavigationCallBack() {
            @Override
            public void callBack() {
                finish();
            }
        });

        DataListAdapter adapter = new DataListAdapter(this, R.layout.data_list_item, getData());
        listView.setAdapter(adapter);

        refreshLayout.setPrimaryColors(Color.parseColor("#FF6955"));
        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                refreshlayout.finishRefresh(2000/*,false*/);
            }
        });
//        refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
//            @Override
//            public void onLoadMore(RefreshLayout refreshlayout) {
//                refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
//            }
//        });
    }

    private List<PersonModel> getData() {
        List<PersonModel> list= new ArrayList<PersonModel>();
        for(int i=0;i<6;i++)
        {
            PersonModel p = new PersonModel();
            p.setNickName("100");
            p.setNoteInfo("200");
            list.add(p);
        }
        return list;
    }
}

